/**
 * 
 */
package org.rollinitiative.d20web.charactersheet.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * @author jmccormi
 * 
 */
public class InitiativeView extends Composite {

    private final TextBox initModText_ = new TextBox();
    private final TextBox currInitText_ = new TextBox();

	public InitiativeView() {
	    Grid initGrid = new Grid(1, 4);
        initGrid.setWidget(0, 0, new Label("Initiative Modifier"));
        initGrid.setWidget(0, 1, initModText_);
        initModText_.setSize("4em", "2em");
        initModText_.setReadOnly(true);
        initGrid.setWidget(0, 2, new Label("Current Initiative"));
        initGrid.setWidget(0, 3, currInitText_);
        currInitText_.setSize("4em", "2em");


		// Hook up events.

		initWidget(initGrid);
		initView();
	}

	private void initView() {
	    initModText_.setText("0");
	    currInitText_.setText("0");
	}

    public void setChararacter(CombatData combat)
    {
        initModText_.setText(modifier(combat.getInitiative()));
        
    }
    
    public String modifier(int modifier) {
        if (modifier > -1) {
            return "+" + modifier;
        }
        else {
            return "" + modifier;
        }
    }
}
